Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce SlowOpenToxic to approximate the TCP handshake latency #536

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

stribioli
Copy link

As discussed in #123, the TCP handshake is performed by the kernel, so toxiproxy cannot inject latency there. Therefore, effects of latency on connection timeouts cannot be tested using this tool.

However, a user might be interested in the overall effects of latency from an application point of view. That is, the end-to-end effect on an entire conversation (TCP connection, application request, application response).

Using the LatencyToxic only, this end-to-end effect is not accurately modeled, because the initial RTT would be missing.
This pull request introduces a new toxic, SlowOpenToxic, that simulates the handshake latency by adding a delay to the first data packet only. I hope you'll find it useful!

Latencies breakdown

In reality, you would have:

  • a 1-RTT delay on the TCP handshake
  • a 1-RTT delay on all subsequent data packets

Using Toxiproxy, with a SlowOpenToxic and a LatencyToxic (with the same delay, equal to 1 RTT), you would have:

  • a 0-RTT delay on the TCP handshake
  • a 2-RTT delay on the first data packet (1-RTT delay added by SlowOpenToxic and 1-RTT delay added by LatencyToxic)
  • a 1-RTT delay on all subsequent data packets (added by LatencyToxic).

Implementation notes

  • The new toxic is derived from LatencyToxic. Once the first packet has been processed, a persisted State records the event and makes the toxic warm. From that point, this toxic is transparent.
  • I extracted a block from the LatencyToxic tests (doLatencyRound) in order to:
    • Re-use it in the SlowOpenToxic tests.
    • Run it multiple times to test the different behavior between LatencyToxic and SlowOpenToxic. To do this, I also tweaked the harness (at toxic_test.go:69) to process multiple packets, instead of stopping at the first one.

Introduce a new toxic (`slow_open` / `SlowOpenToxic`) that adds a
delay to the first data packet of a new TCP connection. This
simulates the delay affecting the TCP handshake (SYN +
SYN/ACK), which is not covered by the `latency` toxic.
Also: improve tests for latency toxic to check that every packet is
subject to the added latency.
@stribioli
Copy link
Author

I have signed the CLA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant